package com.atguigu.dga.assessor.security;

import com.atguigu.dga.assessor.Assessor;
import com.atguigu.dga.governance.bean.AssessParam;
import com.atguigu.dga.governance.bean.GovernanceAssessDetail;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Component("SECURITY_LEVEL")
public class SecurityLevelAssessor extends Assessor {

    @Override
    public void checkProblem(GovernanceAssessDetail governanceAssessDetail, AssessParam assessParam) {

        String securityLevel = assessParam.getTableMetaInfo().getTableMetaInfoExtra().getSecurityLevel();

        if(securityLevel==null || securityLevel.equals("UNSET")){
            //分数置零
            governanceAssessDetail.setAssessScore(BigDecimal.ZERO);
            //提示
            governanceAssessDetail.setAssessProblem("未设置安全级别");
            //获取通用路径
            String governanceUrl = assessParam.getGovernanceMetric().getGovernanceUrl();
            //路径替换
            governanceUrl=governanceUrl.replace("{tableId}",assessParam.getTableMetaInfo().getId() + "");
            governanceAssessDetail.setGovernanceUrl(governanceUrl);
        }
    }
}
